export default (Vue) => {
  Vue.prototype.$showLoading = (title) => {
    wx.showLoading({
      title,
      mask: true
    })
  }
  Vue.prototype.$hideLoading = () => {
    wx.hideLoading()
  }
  Vue.prototype.$showToast = (options = {}) => {
    const { title, duration = 2000, icon, success } = options

    wx.showToast({
      title,
      icon,
      duration,
      mask: true,
      success: () => {
        if (success) {
          setTimeout(() => {
            success()
          }, duration - 500)
        }
      }
    })
  }
}
